"use strict";
const { app, BrowserWindow, ipcMain, webContents } = require("electron");
const path = require("path");
const vueProjectAddress = "http://localhost:5173";
const createWindow = () => {
  const win = new BrowserWindow({
    minWidth: 1e3,
    minHeight: 600,
    width: 1e3,
    height: 600,
    frame: false,
    // 窗口无边框
    titleBarStyle: "hidden",
    webPreferences: {
      nodeIntegration: true,
      // 渲染进程使用Node API
      contextIsolation: false
      // 是否开启隔离上下文
    }
  });
  if (app.isPackaged) {
    win.loadFile(path.join(__dirname, "../index.html"));
  } else {
    win.loadURL(vueProjectAddress);
  }
};
app.whenReady().then(() => {
  createWindow();
  app.on("activate", () => {
    if (BrowserWindow.getAllWindows().length === 0)
      createWindow();
  });
});
app.on("window-all-closed", () => {
  if (process.platform !== "darwin") {
    app.quit();
  }
});
